var mongoose = require("mongoose");
mongoose.connect('mongodb://localhost/test'); 

var db = mongoose.connection;
db.once('open', function(err){
    console.log("数据库成功打开！");
});

var blogSchema = new mongoose.Schema({
    title: String,
    author: String,
    body: String,
    comments: [{body: String,date: Date}],
    date: {type: Date,default: Date.now},
    hidden: Boolean,
    meta: {
        votes: Number,
        favs: Number
    }
});

blogSchema.methods.showInfo = function(){
    console.log(this.title);
}

var Blog = mongoose.model('Blog',blogSchema);
var blog = new Blog({
    "title": "博客测试",
    "author": "陈伟霆",
});
blog.save();